package org.example;


import java.io.IOException;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.SocketException;

public class Main {
    public static void main(String[] args) throws IOException, InterruptedException {



        //本机发送端口设置,因为多次设置同一个ip监听会报错，不可以重复设置同一个端口IP进行监听
        SocketAddress clienSocket;
        clienSocket = new InetSocketAddress("192.168.100.246",608);
        DatagramSocket socket = new DatagramSocket(clienSocket);



        /*
        * TODO 启动程序
        * */
        String device1serverIp="192.168.100.151";
        String device2serverIp="192.168.100.152";
        String device3serverIp="192.168.100.153";
        UDPClient udpClient1 = new UDPClient(socket,device1serverIp,false,true,false);
        UDPClient udpClient2 = new UDPClient(socket,device2serverIp,false,true,false);
        UDPClient udpClient3 = new UDPClient(socket,device3serverIp,false,true,false);

        Thread thread1 = new Thread(udpClient1);
        Thread thread2 = new Thread(udpClient2);
        Thread thread3 = new Thread(udpClient3);

        MyConsumer myConsumer = new MyConsumer();
        Thread thread4 = new Thread(myConsumer);


        thread4.start();

        thread1.start();
        thread2.start();
        thread3.start();


//        Runnable ra = new Runnable() {
//            @Override
//            public void run() {
//                /*
//                 * 消费数据到Mysql
//                 * */
//                Consumer consumer = new Consumer("temp");
//                consumer.mysql_consume();
//            }
//        };
//        Thread thread = new Thread(ra);
//        thread.start();


//        SendCode sendCode=new SendCode("192.168.100.152");

    }



}

